<template>
	<div class="myFun">
		<ul>
            <Loadmore
				:bottom-method="loadBottom"
                :bottom-all-loaded="allLoaded"
                ref="loadmore"
                :autoFill="false"
            >
            <div class='mc' v-if="list.length<1">
                <!-- <img src="../../image/no_collection@2x.png" width='110' alt=""> -->
                <p>暂无粉丝!</p>
            </div>
            <li v-for="(item,index) in list" :key='index' v-if="list.length>0">
	  			<a>
	  			    <p>
                        <img :src="item.pic?item.pic:''" width="45" height="45" alt="">
		            </p>
		            <div>
		           		<h3>{{item.username?item.username:''}}</h3>
			            <p>
			              <!-- <img src="../../image/icon_video_quantity_normal.png" width="13" height="13"> -->
			              <!-- <b>15</b> -->
			              <!-- <span>粉丝:</span> -->
			              <!-- <b>24万</b> -->
		             	</p>
		            </div>
	  			</a>
	  			<div>
	  				<!-- <img src="../../image/icon_add_attention.png" width="27" height="27"> -->
	  			</div>
            </li>
            </Loadmore>
  		</ul>
	</div>
</template>
<script>
    import {Loadmore} from 'mint-ui';
	export default {
		data() {
			return {
                list: [],
                userid: '',
                sentPage: {
					page: 1
                },
                allLoaded: false,
				totalNum: 0, 	//总数据条数
			}
		},
		components: {
			Loadmore
		},
		methods: {
            //获取我的粉丝列表
            getFuns(params) {
                this.userid = localStorage.getItem("loginMobile");
                this.allLoaded = false;
                // 第一个参数是root--baseurl
                this.$api.post(this.$api.baseURLSchool,"selecttype/attention/0?type=fans&id="+this.userid,params,r => {
                    this.totalNum = r.data.records;
                    // if(r.data.pagecount == 1) {
                    //     this.allLoaded = true;
                    // }
					if(this.sentPage.page==1) {
						this.list = r.data.rows;
					}else {
						this.list = this.list.concat(r.data.rows);
					}
					if(r.data.rows.length == 0 && this.sentPage.page > 1) {
						this.$utils._toast("暂无更多数据");
                    }
                    if(this.totalNum == this.list.length) {
                        this.allLoaded = true;
                    }
					var that = this;
					this.list.forEach(function(item,index) {
					// 	//根据用户id(userid)获取用户表详情
						that.$api.get(that.$api.baseURLSchool,"select_cid/user/"+item.userid,{},r => {
							that.$set(that.list,index,Object.assign(r.data.info,that.list[index]));
						},err =>  {
							console.log(err);
						})
					});
                },err => {
                    console.log(err);
                })
            },
            //下拉刷新
			loadTop() {
				this.sentPage.page =1;
			  	setTimeout(() => {
		        	this.getFuns(this.sentPage);
		        }, 20);
			  	this.$refs.loadmore.onTopLoaded();
			},
            //上拉加载
			loadBottom() {
				(this.sentPage.page)++;
		        setTimeout(() => {
		        	this.getFuns(this.sentPage);
		        }, 20);
		        if(this.totalNum == this.list.length) {
					this.allLoaded = true;
		        }
				this.$refs.loadmore.onBottomLoaded();
			},
		},
		created() {
            this.getFuns(this.sentPage);
		}
	}
</script>
<style lang="scss" scoped>
    .mc {
        padding: 40px 0;
        img {
            display: block;
            margin: 0 auto;
            width: 110px !important;
            height: 143px;
        }
        p {
            padding-top: 10px;
            text-align: center;
        }
    }
</style>
